import datetime
import random
import math
import sys

#sys.setrecursionlimit(2000)  # 增加递归深度限制

def my_print(*args, **kwargs):
	if 'flush' not in kwargs:
		kwargs['flush'] = True
	print(*args, **kwargs)

def dfs(workstemp, works, wsl):
	for k in range(wsl):
		if not works[k]['flag']:
			workstemp.append(works[k])
			workstemp_tail_ddl = workstemp[-1]['deadline']
			sumcostt_workstemp = sum(wt['costtime'] for wt in workstemp)
			if workstemp_tail_ddl >= sumcostt_workstemp:
				works[k]['flag'] = True
				my_print({'total value': sum(wt['value'] for wt in workstemp),'jobseqs': [wt['id'] for wt in workstemp]})
				dfs(workstemp, works, wsl)
				works[k]['flag'] = False
			workstemp.pop()

def generate_works(n):
	works = []
	for _ in range(1, n):
		rand_int = random.randint(_, _ * 2)
		works.append({
			'id': int(_),
			'costtime': n - int(_),
			'deadline': (n - int(_)) * 2 + 2,
			'value': rand_int + random.randint(1, _)
		})
	return works

def main():
	n = random.randint(5, 10)
	works = generate_works(n)
	wsl = len(works)
	my_print(wsl)

	for i in range(wsl):
		for work in works:
			work['flag'] = False
			
		workstemp = []
		works[i]['flag'] = True
		workstemp.append(works[i])
		my_print({'total value': sum(wt['value'] for wt in workstemp),'jobseqs': [wt['id'] for wt in workstemp]})
		dfs(workstemp, works, wsl)

if __name__ == '__main__':
	start = datetime.datetime.now()
	main()
	end = datetime.datetime.now()
	my_print('start time:', start)
	my_print('end time:', end)
	total = end - start
	my_print('total time:', total, '\n')